package com.jyh.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.jyh.service.PersonOrderService;
import com.jyh.service.PersonService;

@RestController
@RequestMapping("/user")
public class PersonInfoController {
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	@Autowired 
	private PersonService personService;
	@Autowired
	private PersonOrderService personOrderService;
	
	@RequestMapping("/info")
	public ModelAndView getInfo(HttpServletRequest request, HttpSession session) {
		try {
			logger.info("begin");
			ModelAndView mv = personService.find(request, session);
			mv = personService.getSelectData(mv);
			return mv;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("\n -------------error信息开始-------------- \n" + e
					+ "\n -----------------error信息结束------------------\n\n");
			return null;
		}
	}
	/**
	 * 个人基础信息
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping("/personInfo")
	public ModelAndView getpersonInfo(HttpServletRequest request, HttpSession session) {
		try {
			logger.info("begin");
			ModelAndView mv = personService.findPersonInfo(request, session);
			return mv;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("\n -------------error信息开始-------------- \n" + e
					+ "\n -----------------error信息结束------------------\n\n");
			return null;
		}
		
	}
	@RequestMapping("/personInfoOrder")
	public ModelAndView getpersonInfoOrder(HttpServletRequest request, HttpSession session) {
		try {
			logger.info("begin");
			ModelAndView mv = personOrderService.findPersonInfo(request, session);
			return mv;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("\n -------------error信息开始-------------- \n" + e
					+ "\n -----------------error信息结束------------------\n\n");
			return null;
		}

	}
	
	
}
